package com.beans;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/7/8
 * \* Time: 14:42
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
@Component
public class UserBeans {

    @Bean (name = {"uesrinfo","user1"})// 【注意事项：只使用一个 @Bean 是无法将对象存储到容器中的】
    public User user1() {
        User user = new User();
        user.setId(1);
        user.setName("张三");
        return user;
    }

    @Bean (name = "user2")// 【注意事项：只使用一个 @Bean 是无法将对象存储到容器中的】
    public User user2() {
        User user = new User();
        user.setId(2);
        user.setName("李四");
        return user;
    }

    @Bean (name = "user3")// 【注意事项：只使用一个 @Bean 是无法将对象存储到容器中的】
//    @Scope("prototype")
    //@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public User user3() {
        User user = new User();
        user.setId(1);
        user.setName("Java");
        return user;
    }


}

